home *** CD-ROM | disk | FTP | other *** search
- * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
- * The C++ Answer Book */
- * Tony Hansen */
- * All rights reserved. */
- include <stream.h>
- include "6_14a.c"
-
- stream &operator<<(ostream &out, complex j)
- return out << "(" << j.re << ", " << j.im << ")"; }
- nline complex complex::operator+(complex j) { complex x(re+j.re, im+j.im); return x; }
- nline complex complex::operator-(complex j) { complex x(re-j.re, im-j.im); return x; }
- nline complex complex::operator-() { complex x(-re, -im); return x; }
- nline complex complex::operator*(complex j) { complex x(re*j.re, im*j.im); return x; }
-
- ain()
-
- complex i = 0.0, j = 1.0;
- cout << "i= " << i << ", j=" << j << "\n";
- i = j + 3.0;
- cout << "i= " << i << ", j=" << j << "\n";
- i = j - 3.0;
- cout << "i= " << i << ", j=" << j << "\n";
- i = -j;
- cout << "i= " << i << ", j=" << j << "\n";
- i = i * j;
- cout << "i= " << i << ", j=" << j << "\n";
- return 0;
-
-